package cn.zlb.frame.infrastructure.util.gateway.merchant;

import cn.zlb.frame.domain.merchant.model.entity.MerchantEntity;
import cn.zlb.frame.domain.merchant.model.valueObj.PayAttachmentBaseValueObj;
import cn.zlb.frame.domain.merchant.model.valueObj.PayTypeValueObj;
import cn.zlb.frame.domain.merchant.repository.gateway.IMerchantPaymentGateway;
import org.springframework.stereotype.Service;

/**
 * @author yangjie.deng@resico.cn
 * @date 2023-11-14 15:25:59
 * @describe class responsibility
 */
@Service
public class MerchantPaymentGateway implements IMerchantPaymentGateway {
    @Override
    public MerchantEntity merchantPayAttachmentFull(MerchantEntity merchantEntity) {
        final PayTypeValueObj payType = merchantEntity.getDefaultPayType();

        String json = "";

        switch (payType) {
            case ALI_PAY:
                // 模拟调用第三方接口返回
                json = "{\"payType\":\"ALI_PAY\",\"appId\":\"alipay0001\",\"appName\":\"众乐邦支付宝商户\",\"aesKey\":\"pay aes key\",\"notifyUrl\":\"www.baidu.com\"}";
                break;
            case WECHAT_PAY:
                // 模拟调用第三方接口返回
                json = "{\"payType\":\"WECHAT_PAY\",\"appId\":\"wechatPay0001\",\"merchantId\":\"众乐邦微信商户\",\"merchantKey\":\"pay aes key\",\"keyPath\": \"D://key//\" ,\"notifyUrl\":\"www.baidu.com\"}";
                break;
            default:
                break;
        }

        final PayAttachmentBaseValueObj valueObj = merchantEntity.payAttachmentConvert(json);
        merchantEntity.setPayAttachmentInfo(valueObj);

        return merchantEntity;
    }
}
